cmake_minimum_required(VERSION 3.10)

#project(pemd)

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17 -Os -g")

set(OTHER_SRC ${CMAKE_CURRENT_SOURCE_DIR}/../common/src/CThreadNotify.cpp 
              ${CMAKE_CURRENT_SOURCE_DIR}/../common/src/CMosquittoManager.cpp)
aux_source_directory(./src SRC)

#include_directories
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../common/include)

#library_directories
link_directories(${CMAKE_CURRENT_SOURCE_DIR}/lib)
LINK_DIRECTORIES(${CMAKE_BINARY_DIR}/src/logger)
LINK_DIRECTORIES(${CMAKE_BINARY_DIR}/src/settings)

add_executable(upgrade ${SRC} ${OTHER_SRC}) # 生成可执行文件

#add_library(pemd STATIC ${SRC}) # 生成静态库
#add_library(pemd SHARED ${SRC}) # 生成动态库或共享库

#TARGET_LINK_LIBRARIES(pemd xxx.so)
TARGET_LINK_LIBRARIES(upgrade libsysinfo.so liblogger.so pthread libssl.so libcrypto.so libmosquitto.so 
                        libsysconfig.so libsettings.so libyaml-cpp.so libcjson.so libdl.so libcurl.so)

add_custom_command(TARGET  upgrade
        POST_BUILD
        COMMAND echo "upgrade builded finished."
        COMMAND echo "${CMAKE_BINARY_PATH}/upgrade"
        COMMAND ${CMAKE_STRIP} "$<TARGET_FILE:upgrade>"
        COMMAND ${CMAKE_COMMAND} -E copy  $<TARGET_FILE:upgrade> ${CMAKE_BINARY_PATH}/upgrade
        COMMENT  "Targets are install finished"
       )
      
#install(TARGETS upgrade LIBRARY DESTINATION ${CMAKE_INSTALL_BINARY_DIR})